package main

import "fmt"

func main() {
	sliceAppend()
}

func slice() {
	// 切片
	arr := [...]int{0, 1, 2, 3, 4, 5, 6, 7}
	s := arr[2:6]
	fmt.Println("arr[2:6]", s)
	// arr[:6] [0 1 2 3 4 5]
	fmt.Println("arr[:6]", arr[:6])
	// arr[2:] [2 3 4 5 6 7]
	fmt.Println("arr[2:]", arr[2:])
	//arr[:] [0 1 2 3 4 5 6 7]
	fmt.Println("arr[:]", arr[:])

}

func sliceAppend() {
	arr := [...]int{0, 1, 2, 3, 4, 5, 6, 7}
	s1 := arr[2:6]
	s2 := s1[3:5]
	s3 := append(s2, 10)
	s4 := append(s3, 11)
	s5 := append(s4, 12)
	fmt.Println(s1)
	fmt.Println(s2)
	fmt.Println(s3)
	fmt.Println(s4)
	fmt.Println(s5)
	fmt.Println(arr)

}
